﻿using System;
using System.ComponentModel.DataAnnotations;
using Actya.Core.Infrastructure;

namespace Actya.Core.Widgets
{
	public abstract class WidgetBase : IWidget
	{
		/// <summary>
		/// Widget identifier.
		/// </summary>
		[Required]
		[Display(AutoGenerateField = false)]
		public string Id { get; set; }

		/// <summary>
		/// The name of the widget type.
		/// </summary>
		[Required]
		public string WidgetTypeName { get; set; }

		/// <summary>
		/// Initialize the widget. 
		/// </summary>
		/// <param name="cmsContext"></param>
		public virtual void Initialize(ICmsContext cmsContext)
		{
			// Not much...
		}

		/// <summary>
		/// Sanitizes Widget content.
		/// </summary>
		/// <param name="sanitize"></param>
		/// <returns></returns>
		public virtual WidgetBase SanitizeContent(Func<string, string> sanitize)
		{
			// Not much either.
			return this;
		}
	}
}
